import { defineStore, createPinia } from 'pinia';
import { ref } from 'vue';

export const useGlobalStore = defineStore('global', () => {
  const loading = ref(false);

  return {
    loading,
  };
});

export const useTenantStore = defineStore('tenant', {
  state: () => ({
    tenantId: '',
  }),
  actions: {
    setTenantId(tenantId: string) {
      this.tenantId = tenantId;
      localStorage.setItem('tenant_id', tenantId);
    },
  },
  getters: {
    getTenantId: state => state.tenantId,
  },
});

const pinia = createPinia();
export default pinia;
